<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
      <el-form-item label="关键字:" prop="keyword">
        <el-input
          size="mini"
          v-model="queryParams.keyword"
          placeholder="请输入问题关键字"
          clearable
          style="width: 240px"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="dataList">
      <el-table-column label="序号" type="index" align="center" min-width="5%"/>
      <el-table-column label="用户昵称" align="center" prop="nickname" key="nickname"/>
      <el-table-column label="用户头像" align="center" key="avatar">
        <template slot-scope="scope">
          <image-preview class="list-img" :src="scope.row.avatar"/>
        </template>
      </el-table-column>
      <el-table-column label="更换前邮箱" align="center" prop="beforeReplacement" key="beforeReplacement"/>
      <el-table-column label="新邮箱" align="center" prop="afterReplacement" key="afterReplacement"/>
      <el-table-column label="更换时间" align="center" prop="createTime">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>
<script>
import { pageList } from '@/api/triones/emailChange'
export default {
  name: "index",
  data () {
    return {
      loading: false,
      showSearch: true,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        keyword: undefined
      },
      dataList: [],
      total: 0,
    }
  },
  created() {
    this.getList();
  },
  methods: {
    getList () {
      this.loading = true
      pageList(this.queryParams).then(response => {
        this.dataList = response.rows
        this.total = response.total
        this.loading = false
      })
    },
    /** 检索 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    }
  }
}
</script>

<style scoped lang="scss">

</style>
